import java.util.Arrays;
import java.util.Random;

/**
 * 需求：有6位评委给选手打分【0-100】的整数，选手最后得分：去掉最高最低后的平均分，打印出来
 * 关键点：一个循环找出来min,max,sum 不要写三个循环
 */
public class JudgesRemark {
    public static void main(String[] args) {
        int[] grades = new int[6];
        generateGrades(grades);
        int max = grades[0];
        int min = grades[0];
        int sum = 0;
        for (int i = 0; i < grades.length; i++) {
            if (grades[i] > max) {
                max = grades[i];
            }
            if (grades[i] < min) {
                min = grades[i];
            }
            sum += grades[i];
        }
        double aver = (sum-max-min)*1.0/(grades.length-2);
        System.out.println("去掉最高分最低分后的平均分:" + aver);
    }

    public static int[] generateGrades(int[] grades) {
        Random random = new Random();
        for (int i = 0; i < grades.length; i++) {
            int grade = random.nextInt(101);
            grades[i] = grade;
        }
        System.out.println("评委分数:" + Arrays.toString(grades));
        return grades;
    }
}
